package com.madi.company.ui.personalCenter.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.aspsine.irecyclerview.baseadapter.BaseReclyerViewAdapter;
import com.madi.company.R;
import com.madi.company.bean.PersonalHomePageEntity;

/**
 * Created by fanjingnan on 2017/2/17.
 */

public class PersonalHomePageAdapter extends BaseReclyerViewAdapter<PersonalHomePageEntity> {


    public PersonalHomePageAdapter(Context context) {
        super(context);
    }

    @Override
    public PersonalHomePageViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        return new PersonalHomePageViewHolder(LayoutInflater.from(mContext).inflate(R.layout.item_personal_home_page, parent, false));
    }

    @Override
    public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
        super.onBindViewHolder(holder, position);
        PersonalHomePageEntity personalHomePageBean = data.get(position);
        PersonalHomePageViewHolder personalHomePageViewHolder = (PersonalHomePageViewHolder) holder;
        personalHomePageViewHolder.tipPicture.setImageResource(personalHomePageBean.getImageId());
        personalHomePageViewHolder.descriptionPicture.setText(personalHomePageBean.getItemName());
        if ("设置".equals(personalHomePageBean.getItemName())) {
            personalHomePageViewHolder.line.setBackgroundColor(mContext.getResources().getColor(R.color.white));
            personalHomePageViewHolder.lineTop.setVisibility(View.VISIBLE);
        } else {
            personalHomePageViewHolder.line.setBackgroundColor(mContext.getResources().getColor(R.color.light_gray_line));
        }
        personalHomePageViewHolder.linear.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
            }
        });
    }

    public static class PersonalHomePageViewHolder extends RecyclerView.ViewHolder {
        ImageView tipPicture;
        TextView descriptionPicture;
        TextView line;
        TextView lineTop;
        LinearLayout linear;

        public PersonalHomePageViewHolder(View itemView) {
            super(itemView);
            tipPicture = (ImageView) itemView.findViewById(R.id.tip_picture);
            descriptionPicture = (TextView) itemView.findViewById(R.id.description_picture);
            line = (TextView) itemView.findViewById(R.id.line);
            linear = (LinearLayout) itemView.findViewById(R.id.linear);
            lineTop = (TextView) itemView.findViewById(R.id.line_top);
        }
    }


}
